package com.foreknow.service.impl;

import com.foreknow.bean.Employee;
import com.foreknow.dao.EmployeeDao;
import com.foreknow.service.EmployeeService;

import java.sql.SQLException;

public class EmployeeServiceImpl implements EmployeeService {
    private EmployeeDao employeeDao;

    public void setEmployeeDao(EmployeeDao employeeDao) {
        this.employeeDao = employeeDao;
    }

    @Override
    public void add(Employee employee) {
//        EmployeeDaoImpl dao = new EmployeeDaoImpl();
        //调用dao层的方法
        try {
            //1.
            //2.
            //3.
            employeeDao.add(employee);
            //提交事务 commit
        } catch (SQLException e) {
            //回滚事务
            e.printStackTrace();
        }
    }

    @Override
    public Employee[] getQueryAll() {
        return employeeDao.getQueryAll();
    }

    @Override
    public Employee getQueryById(int id) {
        return employeeDao.getQueryById(id);
    }

    @Override
    public Employee update(Employee employee) {
        return employeeDao.update(employee);
    }
}
